//
//  ViewController.m
//  CAKeyframeAnimationOpacity
//
//  Created by Xwoder on 17/1/29.
//  Copyright © 2017年 Xwoder. All rights reserved.
//

#import "ViewController.h"
#import "UIView+ALQuickFrame.h"

@interface ViewController ()

@property (nonatomic, weak) UIView *orangeView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    UIView *orangeView = [[UIView alloc] init];
    orangeView.backgroundColor = [UIColor orangeColor];
    orangeView.size = CGSizeMake(320, 320);
    orangeView.center = self.view.center;
    [self.view addSubview:orangeView];
    self.orangeView = orangeView;
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    CAKeyframeAnimation *animation = [CAKeyframeAnimation animation];
    animation.keyPath = @"opacity";
    NSArray<NSNumber *> *values = @[@(0.95), @(0.90), @(0.88), @(0.85), @(0.35), @(0.05), @(0.00)];
    animation.values = values;
    animation.duration = 2;
    animation.autoreverses = YES;
    [self.orangeView.layer addAnimation:animation forKey:nil];
}

@end
